import request from '@/utils/request'
import Vue from 'vue'

// 创建付惠吧券
export function saveKdCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/kd',
    method: 'post',
    data: data
  })
}

// 创建微信支付券
export function saveWxPayCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/wxPay',
    method: 'post',
    data: data
  })
}

// 创建微信商家券
export function saveWxBusiCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/wxBusi',
    method: 'post',
    data: data
  })
}

// 券状态
export function couponStatus(data) {
  return request({
    url: '/couponAdmin/coupon/status',
    method: 'post',
    data: data
  })
}

// update
export function updateCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/update',
    method: 'put',
    data: data
  })
}

export function receiveQrCode(params) {
  return request({
    url: '/couponAdmin/coupon/receiveQrCode',
    method: 'get',
    params: params
  })
}

// 同步渠道
export function syncWxCoupon(params) {
  return request({
    url: '/couponAdmin/coupon/syncWxCoupon',
    method: 'post',
    params: params
  })
}

// 券列表
export function couponList(data) {
  return request({
    url: '/couponAdmin/coupon/list',
    method: 'post',
    data: data
  })
}

// 券列表
export function getCanUseCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/getCanUseCoupon',
    method: 'post',
    data: data
  })
}

// 券列表
export function searchCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/searchCoupon',
    method: 'post',
    data: data
  })
}

// 券详情
export function couponDetail(params) {
  return request({
    url: '/couponAdmin/coupon/detail',
    method: 'get',
    params: params
  })
}

// 券详情
export function couponVerifyShops(params) {
  return request({
    url: '/couponAdmin/coupon/verifyShops',
    method: 'get',
    params: params
  })
}

// 券投放统计
export function couponIssueCount(data) {
  return request({
    url: '/couponAdmin/records/coupon/issueCount',
    method: 'post',
    data: data
  })
}

// 券投放列表
export function couponIssueList(data) {
  return request({
    url: '/couponAdmin/records/coupon/issueList',
    method: 'post',
    data: data
  })
}

// 券投放统计
export function couponVerifyCount(data) {
  return request({
    url: '/couponAdmin/records/coupon/verifyCount',
    method: 'post',
    data: data
  })
}

// 券投放列表
export function couponVerifyList(data) {
  return request({
    url: '/couponAdmin/records/coupon/verify',
    method: 'post',
    data: data
  })
}

// 领券中心
export function couponShelf(data) {
  return request({
    url: '/couponAdmin/coupon/couponShelf',
    method: 'post',
    data: data
  })
}

// 上架领券中心
export function upCouponShelf(params) {
  return request({
    url: '/couponAdmin/coupon/shelf/up',
    method: 'post',
    params: params
  })
}

// 下载货架
export function downCouponShelf(params) {
  return request({
    url: '/couponAdmin/coupon/shelf/down',
    method: 'post',
    params: params
  })
}

// 下载货架
export function downWxPayCouponVerifyFile(params) {
  return request({
    url: '/couponAdmin/coupon/wxPayCouponVerifyFile',
    method: 'get',
    params: params,
    responseType: 'blob'
  })
}

// 上架领券中心
export function couponCenterQrCode() {
  return request({
    url: '/couponAdmin/coupon/couponCenterQrCode',
    method: 'get'
  })
}

// 根据ids查询券原型ids
export function getCardCouponByIds(params) {
  return request({
    url: '/couponAdmin/coupon/prototype?' + Vue.prototype.$qs.stringify(params, { indices: false }),
    method: 'get'
  })
}

// 获取商户id配置
export function getMchIdBindInfo() {
  return request({
    url: '/couponAdmin/coupon/mchidBindInfo',
    method: 'get'
  })
}

// 保存商户id配置
export function saveMchIdBindInfo(data) {
  return request({
    url: '/couponAdmin/coupon/bindMchid',
    method: 'post',
    data: data
  })
}

// 保存商户id配置
export function syncWxPayCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/syncWxPayCoupon',
    method: 'post',
    data: data
  })
}

/* 券列表-表格 */
// 上架
export function newUpAndDown(data) {
  return request({
    url: '/couponAdmin/coupon/newUpAndDown',
    method: 'post',
	data: data
  })
}
// 终止
export function stopCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/status',
    method: 'post',
	data: data
  })
}
// 启用
export function openUpCoupon(data) {
  return request({
    url: '/couponAdmin/coupon/openUp',
    method: 'post',
	data: data
  })
}
// 删除
export function deleteDraft(data) {
  return request({
    url: '/couponAdmin/coupon/deleteDraft',
    method: 'post',
	data: data
  })
}

// 券详情
// 保存并上架
export function saveAndUp(data) {
  return request({
    url: '/couponAdmin/coupon/saveAndUp',
    method: 'post',
    data: data
  })
}
